import java.util.*;

public class Main {
    static class TreeNode{
        char val;
        TreeNode left;
        TreeNode right;

        public TreeNode(char val) {
            this.val = val;
        }
    }

    private static int i = 0;

    private static TreeNode dfs(String s){
        if(i == s.length()){
            return null;
        }
        if(s.charAt(i) == '#'){
            i++;
            return null;
        }
        TreeNode cur = new TreeNode(s.charAt(i));
        i++;
        cur.left = dfs(s);
        cur.right = dfs(s);
        return cur;
    }

    private static void inTraversal(TreeNode root){
        if(root == null){
            return;
        }
        inTraversal(root.left);
        System.out.print(root.val + " ");
        inTraversal(root.right);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String str = in.nextLine();
            TreeNode root = dfs(str);
            inTraversal(root);
        }
    }
}
